package Buildings.dwelling;
import Interfaces.*;
public class Flat implements Space, java.io.Serializable, Cloneable{//квартира жилого дома
    static private int DEFAULT_ROOM=2;
    static private double DEFAULT_AREA=50;
   
    private double area;
    private int room;
    
    @Override
    public int getHowMuchRooms(){
        return this.room;
    }
    @Override
    public void setRooms(int room){
        this.room=room;
    }
    @Override
    public double getHowMuchArea(){
        return this.area;
    }
    @Override
    public void setArea(double area){
        this.area=area;
    }

    public String toString(){
        return " квартира: s="+area+" k="+room+" |";
    }
    public boolean equals(Object o){
        boolean answer=false;
        if(o.getClass()==this.getClass()){
            if(((Flat)o).getHowMuchArea()==this.area && ((Flat)o).getHowMuchRooms()==this.room){
                answer=true;
            }
        }
        return answer;
    }
    
    public int hashCode(){
        int hash=(int)(Integer.bitCount(this.room) ^ (Double.doubleToLongBits(this.area) >> 32) ^ (Double.doubleToLongBits(this.area) << 32));
        return hash;
    }
    public Object clone(){
        return new Flat(this.room,this.area);
    }
    
    //конструкторы
    public Flat(){
        room=DEFAULT_ROOM;
        area=DEFAULT_AREA;
    }
    public Flat(double area){
        room=DEFAULT_ROOM;
        this.area=area;
    }
    public Flat(int room,double area){
        this.room=room;
        this.area=area;
    }
}